import { Component , ViewChild } from '@angular/core';
import { NavController , Slides ,AlertController} from 'ionic-angular';
import { NewsPage } from '../news/news';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html',

})
export class HomePage {
  @ViewChild(Slides) slides: Slides;
  public noticeList = [];
  public applyList = [];

  constructor(
    public navCtrl: NavController,
    public alertCtrl: AlertController,
  ) {
    for(var i=0;i<20;i++){
      this.noticeList.push("这是第"+i+"条数据")
    }
    for(var y=0;y<7;y++){
      this.applyList.push("第"+y+"个")
    }
  }

  goNews(){
    this.navCtrl.push(NewsPage)
  }
  goEdit(){
    let alert = this.alertCtrl.create({
         title:"拜托，别点了",
         subTitle:"洗洗睡吧->_->",
         buttons:["ok"]      
    })
    alert.present();
  }
  goToSlide(){
    this.slides.slideTo(2,500);
  }
  slideChanged(){//添加事件监听
    let currentIndex = this.slides.getActiveIndex();
    console.log("current index is",currentIndex)
  }
  /*
  * 解决切换其他页面回去轮播图不动问题
  */ 
   ionViewWillEnter(){
     this.slides.startAutoplay();
   }
   ionViewWillLeave(){
     this.slides.stopAutoplay();
  }
}
